<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jsTree test</title>
<!-- 2 load the theme CSS file -->
<%@include file="/WEB-INF/jsp/admin/public/cssHeader.jsp"%>
<%@include file="/WEB-INF/jsp/admin/public/jsBottom.jsp"%>
</head>
<body class="white-bg">
	<div class="row">
		<div id="myTabContent" class="tab-content">
			<!--板块的分页-->
			<div class="tab-pane fade active in wrapper wrapper-content" id="A">
				<form id="formid"  name="defaultForm"
					action="${pageContext.request.contextPath}/admin/resource/postEditPrivilege.html"
					method="post" enctype="multipart/form-data" class="form-horizontal" role="form">
					<input id="roleId" name="roleId" value="${roleId }" type="hidden"/>
					<div class="form-group">
						<div class="col-sm-6">
							<div id="jstree"></div>
						</div>
					</div>
					
					<div class="form-group">
						<div class="col-sm-6">
							<a id="sub" class="btn btn-primary btn-sm">提交</a>
						</div>
					</div>
					
				</form>
			</div>
		</div>
	</div>
</body>

<body>
	<script>
		$(function() {
			// 6 create an instance when the DOM is ready
			// 			$('#jstree').jstree({
			// 				"plugins" : [ "checkbox" ],
			// 			});

			// 7 bind to events triggered on the tree
			$('#jstree').jstree({
				'plugins' : [ "checkbox" ],
				'core' : {
					'data' : ${data}
				}
			});
		});

		$("#sub").click(function() {
			var nodes = $("#jstree").jstree("get_selected"); //使用get_checked方法 
			$.each(nodes, function(i, n) {
				alert(n);
				var text = "<input name='resourseIds' type='hidden' value='"+n+"'/>";
				$("#roleId").append(text);
				if(nodes.length == i+1){
// 					document.getElementById("formid").submit();
				}
			});
		});
	</script>
</body>
</html>

